/* Copyright (c) 2016 Qualcomm Technologies International, Ltd. */
/*   %%version */
/**
 * \file
 * Implements remote panic reporting.
 */ 

#include "panic/panic_private.h"


void panic_from_p0(uint16 id, uint32 t, uint32 arg)
{
    UNUSED(t);
    UNUSED(arg);
    L0_DBG_MSG2("Received panic from P0: ID %d, arg 0x%08x", id, arg);

    switch (id)
    {
    case PANIC_SYSTEM_MANAGER_PANICKED:
    case PANIC_BTSS_PANICKED:
    case PANIC_AUDIO_PANICKED:
    case PANIC_UNKNOWN_SS_PANICKED:
    case PANIC_BTSS_SUBSYSTEM_WATCHDOG:
    case PANIC_AUDIO_SUBSYSTEM_WATCHDOG:
    case PANIC_APPS_SUBSYSTEM_WATCHDOG:
    case PANIC_UNKNOWN_SS_SUBSYSTEM_WATCHDOG:
        panic_diatribe((panicid) id, arg);

    default:
        panic_diatribe(PANIC_P0_PANICKED, id);
    }
}


void panic_report_down(panicid id, uint32 t, DIATRIBE_TYPE arg)
{

#ifdef IPC_MODULE_PRESENT
    /* Don't inform P0 that it has sent us a panic */
    switch (id)
    {
    case PANIC_SYSTEM_MANAGER_PANICKED:
    case PANIC_BTSS_PANICKED:
    case PANIC_AUDIO_PANICKED:
    case PANIC_UNKNOWN_SS_PANICKED:
    case PANIC_BTSS_SUBSYSTEM_WATCHDOG:
    case PANIC_AUDIO_SUBSYSTEM_WATCHDOG:
    case PANIC_APPS_SUBSYSTEM_WATCHDOG:
    case PANIC_UNKNOWN_SS_SUBSYSTEM_WATCHDOG:
    case PANIC_P0_PANICKED:
        break;

    default:
        ipc_send_panic(id, t, arg);
        break;
    }
#else /* IPC_MODULE_PRESENT */
    UNUSED(id);
    UNUSED(t);
    UNUSED(arg);
#endif /* else IPC_MODULE_PRESENT */

}

